<!-- $Id: goods_list.htm 17126 2010-04-23 10:30:26Z liuhui $ -->

{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}

<!-- 商品搜索 -->
{include file="goods_img_search.htm"}
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
{/if}
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>
      <input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
      <a href="javascript:listTable.sort('img_id'); ">{$lang.record_id}</a>{$sort_goods_id}
    </th>
    <th><a href="javascript:listTable.sort('img_name'); ">{$lang.goods_name}</a>{$sort_goods_name}</th>
    <th><a href="javascript:listTable.sort('img_price'); ">{$lang.shop_price}</a>{$sort_shop_price}</th>
    <th><a href="javascript:listTable.sort('is_best'); ">{$lang.is_best}</a>{$sort_is_best}</th>
    <th><a href="javascript:listTable.sort('is_new'); ">{$lang.is_new}</a>{$sort_is_new}</th>
    <th><a href="javascript:listTable.sort('is_hot'); ">{$lang.is_hot}</a>{$sort_is_hot}</th>
    <th width="200">{$lang.handler}</th>
  <tr>
  {foreach from=$goods_img_list item=goods_img}
  <tr id="gallery_{$goods_img.img_id}">
    <td><input type="checkbox" name="checkboxes[]" value="{$goods_img.img_id}" />{$goods_img.img_id}</td>
    <td class="first-cell"><span onclick="listTable.edit(this, 'edit_goods_name', {$goods_img.img_id})">{$goods_img.img_name|escape:html}</span></td>
    <td align="right"><span onclick="listTable.edit(this, 'edit_goods_price', {$goods_img.img_id})">{$goods_img.img_price}</span></td>
    <td align="center"><img src="images/{if $goods_img.is_best}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_best', {$goods_img.img_id})" /></td>
    <td align="center"><img src="images/{if $goods_img.is_new}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_new', {$goods_img.img_id})" /></td>
    <td align="center"><img src="images/{if $goods_img.is_hot}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_hot', {$goods_img.img_id})" /></td>
    <td align="center">
      <a href="../goods.php?cid={$goods_img.cat_id}&img_id={$goods_img.img_id}" target="_blank" title="{$lang.view}"><img src="images/icon_view.gif" width="16" height="16" border="0" /></a>
      <a href="goods_img.php?act=edit&img_id={$goods_img.img_id}" title="{$lang.edit}"><img src="images/icon_edit.gif" width="16" height="16" border="0" /></a>
      <a href="javascript:;" onclick="if (confirm('{$lang.drop_img_confirm2}')) dropImg('{$goods_img.img_id}')" title="{$lang.delete}"><img src="images/no.gif" border="0" /></a>
    </td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end goods list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>

{if $full_page}
</div>

</form>

<script type="text/javascript">
  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}

  {literal}
  onload = function()
  {
    startCheckOrder(); // 开始检查订单
    document.forms['listForm'].reset();
  }

  /**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'trash')
      {
          return confirm(batch_trash_confirm);
      }
      else if (frm.elements['type'].value == 'not_on_sale')
      {
          return confirm(batch_no_on_sale);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext && frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }

  function changeAction()
  {
      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';
			
			{if $suppliers_list > 0}
      frm.elements['suppliers_id'].style.display = frm.elements['type'].value == 'suppliers_move_to' ? '' : 'none';
			{/if}

      if (!document.getElementById('btnSubmit').disabled &&
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }

  /**
   * 鍒犻櫎鍥剧墖
   */
  function dropImg(imgId)
  {
    Ajax.call('goods.php?is_ajax=1&act=drop_image', "img_id="+imgId, dropImgResponse, "GET", "JSON");
  }

  function dropImgResponse(result)
  {
      if (result.error == 0)
      {
          document.getElementById('gallery_' + result.content).style.display = 'none';
      }
  }

{/literal}
</script>
{include file="pagefooter.htm"}
{/if}